<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="80px">
      <el-form-item label="客户名称" prop="smsName">
        <el-input v-model="queryParams.smsName" placeholder="请输入客户名称" clearable style="width: 220px"
          @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label="模板名称" prop="tplName">
        <el-input v-model="queryParams.tplName" placeholder="请输入模板名称" clearable style="width: 220px"
          @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label="模板ID" prop="tplId">
        <el-input v-model="queryParams.tplId" placeholder="请输入模板ID" clearable style="width: 220px"
          @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label="签名名称" prop="signatureName">
        <el-input v-model="queryParams.signatureName" placeholder="请输入模板名称" clearable style="width: 220px"
          @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label="版式类型" prop="cardId">
        <el-select v-model="queryParams.cardId" placeholder="请选择版式类型" clearable style="width: 220px">
          <el-option v-for="dict in dict.type.card_id" :key="dict.value" :label="dict.label" :value="dict.value" />
        </el-select>
      </el-form-item>
      <el-form-item label="审核状态" prop="auditState">
        <el-select v-model="queryParams.auditState" placeholder="请选择审核状态" clearable style="width: 220px">
          <el-option label="待审核" value="0" />
          <el-option label="审核中" value="1" />
          <el-option label="已通过" value="2" />
          <el-option label="已拒绝" value="3" />
        </el-select>
      </el-form-item>
      <el-form-item label="模板状态" prop="tplState">
        <el-select v-model="queryParams.tplState" placeholder="请选择模板状态" clearable style="width: 220px">
          <el-option label="正常" value="1" />
          <el-option label="禁用" value="0" />
        </el-select>
      </el-form-item>
      <el-form-item label="创建时间" prop="createTime">
        <el-date-picker v-model="queryParams.createTime" type="daterange" value-format="yyyy-MM-dd" range-separator="至"
          start-placeholder="开始日期" end-placeholder="结束日期" style="width: 240px" />
      </el-form-item>
      <el-form-item label="创建人" prop="tplState">
        <el-select v-model="queryParams.tplState" placeholder="请选择模板状态" clearable style="width: 220px">
          <el-option label="正常" value="1" />
          <el-option label="禁用" value="0" />
        </el-select>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>

    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button type="primary" plain icon="el-icon-plus" size="mini" @click="handleAdd"
        >新增</el-button>
      </el-col>
      <el-col :span="1.5" v-if="false">
        <el-button type="danger" plain icon="el-icon-circle-check" size="mini" :disabled="selectedIds.length !== 1"
          @click="handleAudit">审核</el-button>
      </el-col>
      <el-col :span="1.5" v-if="false">
        <el-button type="warning" plain icon="el-icon-delete" size="mini" :disabled="selectedIds.length === 0"
          @click="handleDelete">删除</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button type="info" plain icon="el-icon-circle-close" size="mini" :disabled="selectedIds.length === 0"
          @click="clearSelection">取消选择</el-button>
      </el-col>
      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>

    </el-row>

    <el-tabs v-model="activeTab" @tab-click="handleTabClick">
      <el-tab-pane label="全部" name="all"></el-tab-pane>
      <el-tab-pane label="审核通过" name="approved"></el-tab-pane>
      <el-tab-pane label="审核中" name="pending"></el-tab-pane>
      <el-tab-pane label="审核拒绝" name="rejected"></el-tab-pane>
      <el-tab-pane label="未提交" name="draft"></el-tab-pane>
    </el-tabs>

    <!-- 卡片模式展示 -->
    <div v-loading="loading" class="template-cards">
      <!-- 创建新模板卡片 -->
      <div class="template-card create-card" @click="handleAdd">
        <div class="card-content">
          <i class="el-icon-plus"></i>
          <p>创建新模板</p>
        </div>
      </div>


      <!-- 模板卡片 -->
      <div v-for="item in SmsTemplateMmsList" :key="item.tmId" class="template-card" :data-status="item.auditState"
        :class="{ 'card-selected': selectedIds.includes(item.tmId) }" @click="toggleCardSelection(item)">
        <div class="card-status">
          <el-tag v-if="item.auditState === 0" size="mini" type="info">未提交</el-tag>
          <el-tag v-else-if="item.auditState === 1" size="mini" type="warning">审核中</el-tag>
          <el-tag v-else-if="item.auditState === 2" size="mini" type="success">审核通过</el-tag>
          <el-tag v-else-if="item.auditState === 3" size="mini" type="danger">审核拒绝</el-tag>
        </div>
        <!-- 选中标记 -->
        <div class="selection-indicator" v-if="selectedIds.includes(item.tmId)">
          <i class="el-icon-check"></i>
        </div>

        <div class="card-image" @click.stop="handlePreview(item)"
          v-if="item.cardId == 'com.hbm.video' || item.cardId == 'com.hbm.ecImageAndText'">
          <video-preview :videoSrc="baseUrl + item.imgUrl"
            v-if="item.imgUrl != null && item.urlLx == '1'"></video-preview>
          <video-preview :videoSrc="item.imgUrl" v-else-if="item.imgUrl != null && item.urlLx == '2'"></video-preview>
          <div v-else class="no-image">
            <i class="el-icon-picture-outline"></i>
          </div>
        </div>
        <div class="card-image" @click.stop="handlePreview(item)" v-else>
          <el-image v-if="item.imgUrl != null && item.urlLx == '1'" :src="baseUrl + item.imgUrl" />
          <el-image v-else-if="item.imgUrl != null && item.urlLx == '2'" :src="item.imgUrl" />
          <div v-else class="no-image">
            <i class="el-icon-picture-outline"></i>
          </div>
        </div>
        <div class="card-info">
          <dict-tag :options="dict.type.card_id" :value="item.cardId"
              style="margin-right: 5px;" />
          <h4 class="card-title">{{ item.tplName }}</h4>
          <!-- <p class="card-meta">{{ item.tplId }}</p> -->
          <div class="card-description" v-if="item.tplContent">{{ item.tplContent }}</div>
        </div>
        <div class="card-footer">
          <div class="card-id" style="width: 130px;">
            <div style="width: 130px;">ID:{{ item.tmId }}</div>
            <div style="width: 130px;">模板编码:{{ item.tplId }}</div>

            <!-- 添加手机厂商图标 -->
            <div class="manufacturer-icons" v-if="item.factoryInfo">
              <svg-icon v-if="item.factoryInfo.includes('HuaWei')" icon-class="huaiwei" class="manufacturer-icon" />
              <svg-icon v-if="item.factoryInfo.includes('HONOR')" icon-class="honor" class="manufacturer-icon" />
              <svg-icon v-if="item.factoryInfo.includes('XIAOMI')" icon-class="xiaomiicon" class="manufacturer-icon" />
              <svg-icon v-if="item.factoryInfo.includes('VIVO')" icon-class="vivo" class="manufacturer-icon" />
              <svg-icon v-if="item.factoryInfo.includes('OPPO')" icon-class="oppo" class="manufacturer-icon" />
              <svg-icon v-if="item.factoryInfo.includes('SAMSUNG')" icon-class="sanxing" class="manufacturer-icon" />
              <svg-icon v-if="item.factoryInfo.includes('ZTE')" icon-class="中兴" class="manufacturer-icon" />
            </div>

          </div>
          <div class="card-operations">
            <!-- 操作按钮行 -->
            <div class="card-actions">
              <el-button type="text" icon="el-icon-view" @click.stop="handlePreview(item)"></el-button>
              <el-button type="text" icon="el-icon-edit" @click.stop="handleUpdate(item)"
               ></el-button>
              <el-button type="text" icon="el-icon-brush" title="模版设计" v-if="item.auditState == ''"
                @click.stop="handleTable(item)" ></el-button>
              <el-button type="text" icon="el-icon-delete" @click.stop="handleDelete(item)"
                v-if="item.auditState == '2' || item.auditState == '0' || item.auditState == '3'"
                title="删除模版"></el-button>
              <el-dropdown style="margin-left: 7px;" size="mini" v-if="item.auditState == '2'" @command="(command) => handleCommand(command, item)">
                <el-button size="mini" type="text" icon="el-icon-s-promotion"></el-button>
                <el-dropdown-menu slot="dropdown">
                  <el-dropdown-item command="handledl" icon="el-icon-key">生成短链</el-dropdown-item>
                  <el-dropdown-item command="handledllist" icon="el-icon-circle-check">查看短链</el-dropdown-item>
                </el-dropdown-menu>
              </el-dropdown>


            </div>

            <!-- 状态开关行 -->
            <div class="switch-container" @click.stop v-if="false">
              <el-switch :value="item.tplState === 1" active-color="#13ce66" inactive-color="#ff4949" @click.stop
                @change="toggleTemplateStatus(item)" :active-text="''" :inactive-text="''">
              </el-switch>
              <span class="switch-status" :class="item.tplState === 1 ? 'status-enabled' : 'status-disabled'">
                {{ item.tplState === 1 ? '已启用' : '已禁用' }}
              </span>
            </div>
          </div>
        </div>

        <!-- 状态指示器 -->
        <div class="status-indicator" :class="getStatusClass(item.auditState)">
          <i :class="getStatusIcon(item.auditState)" :title="item.auditDesc" style="cursor: pointer;"></i>
          <span>{{ getStatusText(item.auditState) }}</span>
        </div>

      </div>

    </div>

    <pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize"
      @pagination="getList" />

    <!-- 添加或修改彩信模板对话框 -->
    <el-dialog :title="title" :visible.sync="open" width="700px" append-to-body>
      <el-form ref="form" :model="form" :rules="rules" label-width="100px">
        <!-- <el-form-item label="版式类型" prop="cardId">
          <el-select v-model="form.cardId" placeholder="请选择版式类型" clearable style="width: 220px">
            <el-option v-for="dict in dict.type.card_id" :key="dict.value" :label="dict.label" :value="dict.value" />
          </el-select>
        </el-form-item> -->
        <el-form-item label="模板名称" prop="tplName">
          <el-input v-model="form.tplName" placeholder="请输入模板名称" />
        </el-form-item>
        <el-form-item label="模板用途" prop="useId">
          <el-radio-group v-model="form.useId">
            <el-radio label="1">商用</el-radio>
            <el-radio label="2">试商用</el-radio>
          </el-radio-group>
        </el-form-item>
        <el-form-item label="使用场景" prop="scene">
          <el-input v-model="form.scene" placeholder="请输入使用场景" />
        </el-form-item>
        <el-form-item label="短信示例" prop="smsExample">
          <el-input v-model="form.smsExample" placeholder="请输入短信示例" />
        </el-form-item>
        <el-form-item label="行业类型" prop="industryId">
          <el-select v-model="form.industryId" placeholder="请选择行业类型" style="width: 100%">
            <el-option label="金融行业" value="1" />
            <el-option label="电商行业" value="2" />
            <el-option label="教育行业" value="3" />
            <el-option label="其他行业" value="4" />
          </el-select>
        </el-form-item>
        <!-- <el-form-item label="手机厂商" prop="factoryInfo">
          <el-select v-model="form.factoryInfo" placeholder="请选择手机厂商" multiple style="width: 100%">
            <el-option label="全部厂商" value="ALL" />
            <el-option label="小米" value="XIAOMI" />
            <el-option label="华为" value="HUAWEI" />
            <el-option label="OPPO" value="OPPO" />
            <el-option label="VIVO" value="VIVO" />
          </el-select>
        </el-form-item> -->
        <!-- <el-form-item label="模板内容" prop="content">
          <div class="template-editor">
            <div class="editor-tools">
              <el-button type="primary" size="mini" icon="el-icon-plus" @click="addImageElement">添加图片</el-button>
              <el-button type="primary" size="mini" icon="el-icon-s-grid" @click="addTextElement">添加文本</el-button>
              <el-button type="primary" size="mini" icon="el-icon-link" @click="addLinkElement">添加链接</el-button>
            </div>
            <div class="editor-canvas"
              style="background-color: #f5f7fa; min-height: 300px; padding: 10px; border: 1px solid #dcdfe6; border-radius: 4px;">
              <p class="editor-placeholder" v-if="!form.content">请添加彩信元素，或直接编辑模板内容</p>
              <div v-else v-html="form.content"></div>
            </div>
          </div>
        </el-form-item> -->
        <el-form-item label="申请说明" prop="description">
          <el-input v-model="form.description" type="textarea" :rows="3" placeholder="请输入申请说明" />
        </el-form-item>
        <!-- <el-form-item label="关联签名" prop="signatureId">
          <el-select v-model="form.signatureId" style="width: 100%;" filterable placeholder="请选择关联签名" clearable
            @change="handleSignatureChange">
            <el-option v-for="item in signaturesList" :key="item.signatureId" :label="item.signatureName"
              :value="item.signatureId"></el-option>
          </el-select>
        </el-form-item> -->
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm">提 交</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>
    <!-- 生成短链对话框 -->
    <el-dialog :title="titleu" :visible.sync="openu" width="500px" append-to-body>
      <el-form ref="formu" :model="formu" :rules="rulesu" label-width="80px">
        <el-form-item label="模版ID" prop="tplId">
          <el-input v-model="formu.tplId" placeholder="请输入模版id" disabled />
        </el-form-item>
        <el-form-item label="签名" prop="smsSigns">
          <el-input v-model="formu.smsSigns" placeholder="请输入签名" />
        </el-form-item>
        <el-form-item label="短链类型" prop="codeType">
              <el-radio v-model="formu.codeType" label="2">个性化</el-radio>
              <el-radio v-model="formu.codeType" label="1">群发</el-radio>
            </el-form-item>
        <el-form-item label="解析次数" prop="showTimes" v-if="formu.codeType=='1'">

          <el-input-number v-model="formu.showTimes" style="width:80%" placeholder="请输入解析次数" :min="1"
            :controls="false"></el-input-number>
          /次
          <el-popover placement="top-start" title="标题" width="300" trigger="hover"
            content="提示：系统会根据输入数量进行扣费，发送短信时请注意不要超过该值，超出部分将无法解析。">
            <i class="el-icon-info" style="color:rgb(1, 152, 253);font-size: 18px; margin-left: 10px;"
              slot="reference"></i>
          </el-popover>
        </el-form-item>
        <el-form-item label="失效天数" prop="expireTimes">
          <el-input-number v-model="formu.expireTimes" style="width:80%" placeholder="短链有效天数不能低于7天，高于30天" :min="1"
            :max="30" :controls="false"></el-input-number>
          /天
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitFormu">确 定</el-button>
        <el-button @click="cancelu">取 消</el-button>
      </div>
    </el-dialog>
    <!-- 查看短链列表 -->
    <el-dialog title="短链列表" :visible.sync="openul" width="600px" append-to-body>
      <el-form label-width="80px">
        <el-table style="overflow: auto; " height="400px" :data="dlList">
          <el-table-column label="短链" align="center" prop="aimUrl" width="140" />
          <el-table-column label="签名" align="left" prop="smsSigns" width="120" />
          <el-table-column label="解析次数" align="left" prop="showTimes" />
          <el-table-column label="有效天数" align="left" prop="expireTimes" />
          <el-table-column label="生成时间" align="left" prop="createTime">
            <template slot-scope="scope">
              <div>{{ parseTime(scope.row.createTime, "{y}-{m}-{d}") }}</div>
            </template>
          </el-table-column>

        </el-table>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button @click="cancelul">关 闭</el-button>
      </div>
    </el-dialog>

    <el-dialog title="查看详情" width="1200px" class="preview-dialog" append-to-body>
      <div class="detail-container">
        <div class="phone-preview">
          <div class="phone-tabs">
            <el-tabs type="card">
              <el-tab-pane v-for="brand in ['华为', '荣耀', '小米', 'vivo', 'OPPO', '三星', '中兴']" :key="brand" :label="brand">
                <div class="phone-mockup">
                  <div class="phone-frame">
                    <div class="phone-header">
                      <div class="phone-camera"></div>
                      <div class="phone-speaker"></div>
                    </div>
                    <div class="phone-screen">
                      <div v-if="previewData.content" v-html="previewData.content" class="phone-screen-content"></div>
                      <div v-else class="no-preview-content">
                        <i class="el-icon-picture-outline"></i>
                        <p>暂无内容</p>
                      </div>
                    </div>
                    <div class="phone-footer">
                      <div class="phone-home-button"></div>
                    </div>
                  </div>
                </div>
              </el-tab-pane>
            </el-tabs>
          </div>
        </div>

        <div class="template-details">
          <div class="detail-section">
            <h3>模板信息</h3>
            <div class="info-grid">
              <div class="info-item">
                <span class="label">模板名称:</span>
                <span class="value">{{ previewData.tplName || '-' }}</span>
              </div>
              <div class="info-item">
                <span class="label">创建人:</span>
                <span class="value">{{ previewData.creator || '-' }}</span>
              </div>
              <div class="info-item">
                <span class="label">模板ID:</span>
                <span class="value">{{ previewData.tmId || '-' }}</span>
              </div>
              <div class="info-item">
                <span class="label">模板用途:</span>
                <span class="value">{{ previewData.tplUse || '-' }}</span>
              </div>
              <div class="info-item">
                <span class="label">模板大小:</span>
                <span class="value">{{ previewData.degreeSize ? (previewData.degreeSize + 'M') : '-' }}</span>
              </div>
              <div class="info-item">
                <span class="label">提交时间:</span>
                <span class="value">{{ previewData.createTime ? parseTime(previewData.createTime) : '-' }}</span>
              </div>
              <div class="info-item">
                <span class="label">识别类型:</span>
                <span class="value">彩信识别</span>
              </div>
              <div class="info-item">
                <span class="label">消息签名:</span>
                <span class="value">{{ previewData.signatureName || '-' }}</span>
              </div>
              <div class="info-item">
                <span class="label">计费模式:</span>
                <span class="value">按条计费</span>
              </div>
            </div>
          </div>

          <div class="detail-section">
            <h3>彩信示例</h3>
            <div class="sms-example">
              <el-input type="textarea" :rows="5" readonly
                :value="previewData.content ? stripHtml(previewData.content) : ''"></el-input>
            </div>
          </div>

          <div class="detail-section">
            <h3>审核信息</h3>
            <div class="info-grid">
              <div class="info-item full-width">
                <span class="label">审核状态:</span>
                <span class="value">
                  <el-tag v-if="previewData.auditState === 0" type="info">未提交</el-tag>
                  <el-tag v-else-if="previewData.auditState === 1" type="warning">审核中</el-tag>
                  <el-tag v-else-if="previewData.auditState === 2" type="success">审核通过</el-tag>
                  <el-tag v-else-if="previewData.auditState === 3" type="danger">审核拒绝</el-tag>
                  <el-tag v-else type="info">未知</el-tag>
                </span>
              </div>
              <div class="info-item full-width" v-if="previewData.auditDesc">
                <span class="label">审核备注:</span>
                <span class="value">{{ previewData.auditDesc }}</span>
              </div>
              <div class="info-item full-width" v-if="previewData.auditState !== '0' && !previewData.auditDesc">
                <span class="label">审核备注:</span>
                <span class="value">-</span>
              </div>
              <div class="info-item full-width">
                <span class="label">可用厂商:</span>
                <span class="value">{{ previewData.factoryInfo || '-' }}</span>
              </div>
            </div>
          </div>
        </div>
      </div>
    </el-dialog>
    <!-- 模版预览 -->
    <el-dialog title="详情预览" :visible.sync="previewOpen" width="1200px" append-to-body>
      <iframe :src="viewurl" width="100%" height="800px">
      </iframe>
    </el-dialog>

    <!-- 审核对话框 -->
    <el-dialog title="智能模板审核" :visible.sync="auditOpen" width="600px" append-to-body destroy-on-close
      :close-on-click-modal="false" @closed="handleAuditClosed">
      <el-form ref="auditForm" :model="auditForm" :rules="auditRules" label-width="100px">
        <el-form-item label="模板名称">
          <span>{{ auditForm.tplName }}</span>
        </el-form-item>
        <el-form-item label="版式类型" prop="cardId">
          <el-select v-model="queryParams.cardId" placeholder="请选择版式类型" clearable style="width: 220px">
            <el-option v-for="dict in dict.type.card_id" :key="dict.value" :label="dict.label" :value="dict.value" />
          </el-select>
        </el-form-item>
        <el-form-item label="审核结果" prop="auditState">
          <el-radio-group v-model="auditForm.auditState">
            <el-radio label="2">通过</el-radio>
            <el-radio label="3">拒绝</el-radio>
          </el-radio-group>
        </el-form-item>
        <el-form-item label="审核意见" prop="auditDesc">
          <el-input type="textarea" v-model="auditForm.auditDesc" :rows="3" placeholder="请输入审核意见"></el-input>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitAudit">确 定</el-button>
        <el-button @click="cancelAudit">取 消</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import { listSmsTemplateMms, getSmsTemplateMms, delSmsTemplateMms, addSmsTemplateMms, updateSmsTemplateMms, getSmsTemplateMmsView } from "@/api/Sms/SmsTemplateMms";
import { listSignatures } from "@/api/Sms/signatures";
import { addSmsTemplateMmsurl, listSmsTemplateMmsurl } from "@/api/Sms/SmsTemplateMmsurl";
import VideoPreview from '@/views/smstask/SmsView/video.vue';
export default {
  name: "SmsTemplateMms",
  components: {
    VideoPreview
  },
  dicts: ["audit_status", "signature_type", 'card_id'],
  data() {
    return {
      baseUrl: process.env.VUE_APP_BASE_API,

      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 当前选中的标签页
      activeTab: 'all',
      // 是否显示预览对话框
      // 预览数据
      previewData: {},
      // 是否显示审核对话框
      auditOpen: false,
      // 审核表单
      auditForm: {
        tmId: null,
        tplName: '',
        tplMsgType: '',
        auditState: '2',
        auditDesc: ''
      },
      // 审核校验规则
      auditRules: {
        auditState: [
          { required: true, message: '请选择审核结果', trigger: 'change' }
        ],
        auditDesc: [
          { required: true, message: '请输入审核意见', trigger: 'blur' }
        ]
      },
      // 阅信模板信息表格数据
      SmsTemplateMmsList: [],
      // 签名列表
      signaturesList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        tplId: null,
        tplName: null,
        auditState: null,
        tplState: null,
        createTime: null
      },
      // 表单参数
      form: {},
      // 表单校验
      rules: {
        cardId: [
          { required: true, message: "版本不能为空", trigger: "blur" }
        ],
        smsExample: [
          { required: true, message: "短信示例不能为空", trigger: "blur" }
        ],
        tplName: [
          { required: true, message: "模板名称不能为空", trigger: "blur" }
        ],
        tplMsgType: [
          { required: true, message: "模板类型不能为空", trigger: "change" }
        ],
        scene: [
          { required: true, message: "使用场景不能为空", trigger: "blur" }
        ],
        industryId: [
          { required: true, message: "行业类型不能为空", trigger: "change" }
        ],
        factoryInfo: [
          { required: true, message: "手机厂商不能为空", trigger: "change" }
        ],
        // signatureId: [
        //   { required: true, message: "关联签名不能为空", trigger: "change" }
        // ]
      },
      // 选中卡片ID
      selectedIds: [],

      previewOpen: false,
      viewurl: "",//预览地址
      titleu: "",
      openu: false,
      openul: false,
      dlList: [],//短链列表
      queryParamsdl: {
        pageNum: 1,
        pageSize: 100,
        tplId: null,

      },
      // 表单参数
      formu: {},
      // 表单校验
      rulesu: {
        tplId: [
          { required: true, message: "模版ID不能为空", trigger: "blur" }
        ],
        smsSigns: [
          { required: true, message: "短信签名不能为空", trigger: "blur" }
        ],
        showTimes: [
          { required: true, message: "解析次数不能为空", trigger: "blur" }
        ],
        expireTimes: [
          { required: true, message: "短链失效天数不能为空", trigger: "blur" }
        ],
      },
    };
  },
  created() {
    this.getList();
    this.getSignaturesList();
  },
  methods: {
    /** 获取当前时间，用于预览 */
    getCurrentTime() {
      const now = new Date();
      const hours = now.getHours().toString().padStart(2, '0');
      const minutes = now.getMinutes().toString().padStart(2, '0');
      return `${hours}:${minutes}`;
    },
    /** 查询签名列表 */
    getSignaturesList() {
      listSignatures({ pageSize: 100, auditStatus: 'successful',userId :this.$store.state.user.userId}).then(response => {
        this.signaturesList = response.rows;

      });
    },
    /** 查询阅信模板信息列表 */
    getList() {
      this.loading = true;
      // 根据当前选中的标签页设置查询条件
      if (this.activeTab !== 'all') {
        switch (this.activeTab) {
          case 'approved':
            this.queryParams.auditState = '2';
            break;
          case 'pending':
            this.queryParams.auditState = '1';
            break;
          case 'rejected':
            this.queryParams.auditState = '3';
            break;
          case 'draft':
            this.queryParams.auditState = '0';
            break;
        }
      } else {
        // 全部标签页，不设置特定审核状态过滤
        this.queryParams.auditState = null;
      }
      this.queryParams.userId = this.$store.state.user.userId;
      listSmsTemplateMms(this.queryParams).then(response => {
        this.SmsTemplateMmsList = response.rows;

        this.total = response.total;
        this.loading = false;
      });
    },
    // 标签页切换
    handleTabClick() {
      this.getList();
    },
    // 添加图片元素
    addImageElement() {
      if (!this.form.content) this.form.content = '';
      this.form.content += '<div class="mms-image"><img src="https://via.placeholder.com/300x200" alt="示例图片" width="100%"/></div>';
    },
    // 添加文本元素
    addTextElement() {
      if (!this.form.content) this.form.content = '';
      this.form.content += '<div class="mms-text"><p>请输入文本内容</p></div>';
    },
    // 添加链接元素
    addLinkElement() {
      if (!this.form.content) this.form.content = '';
      this.form.content += '<div class="mms-link"><a href="https://example.com">点击这里访问链接</a></div>';
    },
    //预览操作
    handlePreview(row) {
      this.previewData = row;
      this.previewOpen = true;
      this.viewurl = null;
      //获取预览地址
      getSmsTemplateMmsView(row.tplId).then(response => {
        this.viewurl = response["msg"];
      }).catch(err => {
        console.error("获取模板详情失败:", err);
        this.$message.error("获取模板详情失败");
      });
    },
    // 审核操作
    handleAudit(row) {
      if (row) {
        // 通过操作按钮点击审核特定行
        console.log('当前选中IDs:', this.selectedIds);
        getSmsTemplateMms(this.selectedIds[0]).then(response => {
          if (response.data) {
            this.auditForm = {
              tmId: response.data.tmId,
              tplName: response.data.tplName,
              tplMsgType: response.data.tplMsgType || '',
              auditState: '2',
              auditDesc: ''
            };
            this.auditOpen = true;
          } else {
            this.$message.error("获取模板数据失败");
          }
        }).catch(err => {
          console.error("获取模板详情失败:", err);
          this.$message.error("获取模板详情失败");
        });
      } else if (this.selectedIds.length === 1) {
        console.log("===========:" + this.selectedIds[0])
        // 通过卡片选择审核
        getSmsTemplateMms(this.selectedIds[0]).then(response => {
          if (response.data) {
            this.auditForm = {
              tmId: response.data.tmId,
              tplName: response.data.tplName,
              tplMsgType: response.data.tplMsgType || '',
              auditState: '2',
              auditDesc: ''
            };
            this.auditOpen = true;
          } else {
            this.$message.error("获取模板数据失败");
          }
        }).catch(err => {
          console.error("获取模板详情失败:", err);
          this.$message.error("获取模板详情失败");
        });
      } else {
        this.$message.error("请选择一个模板进行审核");
      }
    },
    // 取消审核对话框
    cancelAudit() {
      this.auditOpen = false;
    },
    // 审核对话框关闭后的回调
    handleAuditClosed() {
      this.auditForm = {
        tmId: null,
        tplName: '',
        tplMsgType: '',
        auditState: '2',
        auditDesc: ''
      };
    },
    // 提交审核
    submitAudit() {
      this.$refs["auditForm"].validate(valid => {
        if (valid) {
          const data = {
            tmId: this.auditForm.tmId,
            auditState: this.auditForm.auditState,
            auditDesc: this.auditForm.auditDesc
          };
          updateSmsTemplateMms(data).then(response => {
            this.$modal.msgSuccess("审核成功");
            this.auditOpen = false;
            this.getList();
          });
        }
      });
    },
    /** 处理签名变更 */
    handleSignatureChange(signatureId) {
      if (signatureId) {
        const selectedSignature = this.signaturesList.find(item => item.signatureId === signatureId);
        if (selectedSignature) {
          this.form.signatureName = selectedSignature.signatureName;
        }
      } else {
        this.form.signatureName = null;
      }
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    // 表单重置
    reset() {
      this.form = {
        tmId: null,
        tplId: null,
        tplName: null,
        tplMsgType: '1',
        scene: null,
        content: null,
        description: null,
        industryId: null,
        factoryInfo: 'ALL',
        signatureId: null,
        signatureName: null,
        auditState: 0,
        tplState: 1,
        useId: "1",
      };
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.activeTab = 'all';
      this.handleQuery();
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map(item => item.tmId)
      this.single = selection.length !== 1
      this.multiple = !selection.length
    },
    /** 新增按钮操作 */
    handleAdd() {
      this.reset();
      this.open = true;
      this.title = "添加图文模板";
    },
    /** 修改按钮操作 */
    handleUpdate(row) {
      this.reset();
      const tmId = row.tmId || this.ids
      getSmsTemplateMms(tmId).then(response => {
        this.form = response.data;
        this.open = true;
        this.title = "添加图文模板";
      });
    },
    /** 模版设计 */
    handleTable(row) {
      console.log(row)
      let routeData = this.$router.resolve({
        path: '/sms/smsview', query: {
          tmId: row.tmId,

        }
      });
      window.open(routeData.href, '_blank');
    },
    /** 提交按钮 */
    submitForm() {
      this.$refs["form"].validate(valid => {
        if (valid) {
          if (this.form.tmId != null) {
            updateSmsTemplateMms(this.form).then(response => {
              this.$modal.msgSuccess("修改成功");
              this.open = false;
              this.getList();
            });
          } else {
            addSmsTemplateMms(this.form).then(response => {
              this.$modal.msgSuccess("新增成功");
              this.open = false;
              this.getList();
            });
          }
        }
      });
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      let tmIds;
      if (row) {
        tmIds = row.tmId;
      } else if (this.selectedIds.length > 0) {
        tmIds = this.selectedIds.join(',');
      } else {
        this.$message.error("请至少选择一个模板");
        return;
      }

      this.$modal.confirm('是否确认删除模板编号为"' + tmIds + '"的数据项？').then(function () {
        return delSmsTemplateMms(tmIds);
      }).then(() => {
        this.getList();
        this.selectedIds = [];
        this.$modal.msgSuccess("删除成功");
      }).catch(() => { });
    },
    /** 生成短链 */
    handleDl(row) {
      this.resetu();
      this.openu = true;
      this.formu.tplId = row.tplId;
      // this.formu.codeType="2";
      this.titleu = "生成短链";
    },
    /** 短链列表 */
    handleDllist(row) {
      this.openul = true;
      this.queryParamsdl.tplId = row.tplId;
      listSmsTemplateMmsurl(this.queryParamsdl).then(response => {
        this.dlList = response.rows;
      });
    },
    // 更多短链操作触发
    handleCommand(command, row) {
      switch (command) {
        case "handledl":
          this.handleDl(row);
          break;
        case "handledllist":
          this.handleDllist(row);
          break;
        default:
          break;
      }
    },
    // 取消按钮
    cancelu() {
      this.openu = false;
      this.resetu();
    },
    // 取消按钮
    cancelul() {
      this.openul = false;
    },
    /** 提交按钮 */
    submitFormu() {
      this.$refs["formu"].validate(valid => {
        if (valid) {
          addSmsTemplateMmsurl(this.formu).then(response => {
            this.$modal.msgSuccess("新增成功");
            this.openu = false;
          });

        }
      });
    },
    // 表单重置
    resetu() {
      this.formu = {
        tplId: null,
        smsSigns: null,
        showTimes: 1,
        expireTimes: null,
        codeType:"2",

      };
      this.resetForm("form");
    },
    // 清除所有选择
    clearSelection() {
      this.selectedIds = [];
    },
    /** 从HTML内容中提取第一张图片的src */
    extractImageSrc(htmlContent) {
      if (!htmlContent) return null;

      const imgRegex = /<img[^>]+src="([^">]+)"/i;
      const match = htmlContent.match(imgRegex);
      return match ? match[1] : null;
    },
    /** 处理模板状态变更 */
    handleStateChange(item) {
      const newState = item.tplState === 1 ? 0 : 1;
      const data = {
        tmId: item.tmId,
        tplState: newState
      };
      updateSmsTemplateMms(data).then(response => {
        this.$modal.msgSuccess("状态修改成功");
        item.tplState = newState;
      });
    },
    /** 将HTML内容转换为纯文本 */
    stripHtml(html) {
      if (!html) return '';
      // 创建临时DOM元素来解析HTML
      const tempDiv = document.createElement('div');
      tempDiv.innerHTML = html;
      // 返回纯文本内容
      return tempDiv.textContent || tempDiv.innerText || '';
    },
    getStatusClass(auditState) {
      switch (auditState) {
        case 0:
          return 'status-ribbon-info';
        case 1:
          return 'status-ribbon-warning';
        case 2:
          return 'status-ribbon-success';
        case 3:
          return 'status-ribbon-danger';
        default:
          return '';
      }
    },
    getStatusText(auditState) {
      switch (auditState) {
        case 0:
          return '未提交';
        case 1:
          return '审核中';
        case 2:
          return '已通过';
        case 3:
          return '审核失败';
        default:
          return auditState;
      }
    },
    getStatusIcon(auditState) {
      switch (auditState) {
        case 0:
          return 'el-icon-info';
        case 1:
          return 'el-icon-warning';
        case 2:
          return 'el-icon-success';
        case 3:
          return 'el-icon-error';
        default:
          return '';
      }
    },
    // 切换卡片选中状态
    toggleCardSelection(item) {
      console.log('切换选中状态:', item.tmId);
      if (this.selectedIds.includes(item.tmId)) {
        console.log('取消选中:', item.tmId);
        this.selectedIds = this.selectedIds.filter(id => id !== item.tmId);
      } else {
        console.log('选中:', item.tmId);
        this.selectedIds.push(item.tmId);
      }
      console.log('当前选中IDs:', this.selectedIds);

      // 更新single状态，保持与原来逻辑一致
      this.single = this.selectedIds.length !== 1;
    },
    getMsgTypeName(tplMsgType) {
      switch (tplMsgType) {
        case '1':
          return '普通模板';
        case '2':
          return '卡片模板';
        default:
          return '未知类型';
      }
    },
    // 处理模板状态变更
    toggleTemplateStatus(item) {
      const newState = item.tplState === 1 ? 0 : 1;
      const data = {
        tmId: item.tmId,
        tplState: newState
      };
      updateSmsTemplateMms(data).then(response => {
        this.$modal.msgSuccess("状态修改成功");
        item.tplState = newState;
      });
    }
  }
};
</script>

<style scoped>
.template-editor {
  width: 100%;
}

.editor-tools {
  margin-bottom: 10px;
  display: flex;
  gap: 10px;
}

.editor-canvas {
  position: relative;
}

.editor-placeholder {
  color: #909399;
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}

.preview-container {
  background-color: #f5f7fa;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid #dcdfe6;
}

.preview-header {
  background-color: #606266;
  color: white;
  padding: 10px 15px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.preview-title {
  font-weight: bold;
}

.preview-content {
  padding: 15px;
  min-height: 300px;
}

.preview-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 300px;
  color: #909399;
}

.preview-empty i {
  font-size: 48px;
  margin-bottom: 10px;
}

.mms-image,
.mms-text,
.mms-link {
  margin-bottom: 15px;
}

.mms-text p {
  margin: 0;
  line-height: 1.5;
}

.mms-link a {
  color: #409eff;
  text-decoration: underline;
}

/* 卡片模式样式 */
.template-cards {
  display: flex;
  flex-wrap: wrap;
  gap: 20px;
  margin-bottom: 20px;
}

/* 模板卡片基础样式 */
.template-card {
  width: 242px;
  height: 320px;
  border-radius: 4px;
  border: 1px solid #ebeef5;
  background-color: #fff;
  overflow: hidden;
  position: relative;
  transition: all 0.3s;
  box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1);
  display: flex;
  flex-direction: column;
}

.template-card:hover {
  box-shadow: 0 4px 16px 0 rgba(0, 0, 0, 0.2);
}

/* 不同状态卡片样式 */
.template-card[data-status="0"] {
  border-top: 3px solid rgba(24, 144, 255, 0.8);
}

.template-card[data-status="1"] {
  border-top: 3px solid rgba(250, 173, 20, 0.8);
}

.template-card[data-status="2"] {
  border-top: 3px solid rgba(82, 196, 26, 0.8);
}

.template-card[data-status="3"] {
  border-top: 3px solid rgba(255, 77, 79, 0.8);
}

.card-status {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 2;
  display: none;
  /* 隐藏原有的状态标签，使用ribbon代替 */
}

.card-image {
  height: 180px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: #f5f7fa;
  position: relative;
  cursor: pointer;
}

.card-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.no-image {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  color: #909399;
}

.no-image i {
  font-size: 48px;
}

.card-info {
  padding: 10px;
  flex-grow: 1;
}

.card-title {
  margin: 0 0 10px 0;
  font-size: 16px;
  font-weight: bold;
  color: #303133;
  display: inline-flex;

  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.card-meta {
  font-size: 14px;
  color: #909399;
  margin-bottom: 10px;
}

.card-description {
  font-size: 13px;
  color: #606266;
  line-height: 1.5;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
}

.card-footer {
  padding: 10px 15px;
  border-top: 1px solid #ebeef5;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  font-size: 12px;
  color: #909399;
  position: relative;
}

.card-id {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.card-operations {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
}

.card-actions {
  display: flex;
  align-items: center;
  /* gap: 5px; */
}

.switch-container {
  display: flex;
  align-items: center;
  background-color: #f9f9f9;
  padding: 3px 8px;
  border-radius: 4px;
  border: 1px solid #ebeef5;
  margin-top: 5px;
  cursor: pointer;
}

.switch-status {
  font-size: 12px;
  font-weight: 500;
  margin-left: 8px;
  /* 放在开关后面 */
}

.status-enabled {
  color: #13ce66;
}

.status-disabled {
  color: #ff4949;
}

.create-card {
  border: 1px dashed #dcdfe6;
  background-color: #f5f7fa;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.create-card:hover {
  background-color: #ecf5ff;
  border-color: #409eff;
}

.create-card .card-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  color: #909399;
}

.create-card i {
  font-size: 40px;
  margin-bottom: 10px;
}

.create-card p {
  font-size: 16px;
}

/* 详情对话框样式 */
.detail-container {
  display: flex;
  gap: 30px;
}

.phone-preview {
  width: 350px;
  flex-shrink: 0;
}

.phone-tabs {
  height: 100%;
}

.phone-tabs :deep(.el-tabs__content) {
  height: calc(100% - 40px);
  overflow: visible;
}

.phone-tabs :deep(.el-tab-pane) {
  height: 100%;
}

.phone-mockup {
  position: relative;
  width: 300px;
  height: 600px;
  margin: 20px auto;
  display: flex;
  justify-content: center;
}

.phone-frame {
  width: 280px;
  height: 560px;
  background-color: #000;
  border-radius: 36px;
  box-shadow: 0 12px 24px rgba(0, 0, 0, 0.2);
  padding: 12px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid #333;
  position: relative;
}

/* 各品牌手机样式定制 */
.el-tabs__item:nth-child(1).is-active~.el-tabs__content .phone-frame {
  /* 华为 */
  border-radius: 36px;
  background: linear-gradient(145deg, #222, #000);
}

.el-tabs__item:nth-child(2).is-active~.el-tabs__content .phone-frame {
  /* 荣耀 */
  border-radius: 30px;
  background: linear-gradient(145deg, #1a1a1a, #000);
}

.el-tabs__item:nth-child(3).is-active~.el-tabs__content .phone-frame {
  /* 小米 */
  border-radius: 20px;
  background: linear-gradient(145deg, #222, #000);
}

.el-tabs__item:nth-child(4).is-active~.el-tabs__content .phone-frame {
  /* vivo */
  border-radius: 40px;
  background: linear-gradient(145deg, #333, #000);
}

.el-tabs__item:nth-child(5).is-active~.el-tabs__content .phone-frame {
  /* OPPO */
  border-radius: 42px;
  background: linear-gradient(145deg, #333, #111);
}

.el-tabs__item:nth-child(6).is-active~.el-tabs__content .phone-frame {
  /* 三星 */
  border-radius: 32px;
  background: linear-gradient(145deg, #222, #000);
}

.el-tabs__item:nth-child(7).is-active~.el-tabs__content .phone-frame {
  /* 中兴 */
  border-radius: 24px;
  background: linear-gradient(145deg, #111, #000);
}

.phone-header {
  height: 30px;
  display: flex;
  justify-content: center;
  align-items: center;
  position: relative;
}

.phone-camera {
  width: 12px;
  height: 12px;
  background-color: #333;
  border-radius: 50%;
  position: absolute;
  top: 8px;
  left: 80px;
}

.phone-speaker {
  width: 60px;
  height: 6px;
  background-color: #333;
  border-radius: 3px;
  position: absolute;
  top: 12px;
}

.phone-screen {
  flex: 1;
  background-color: #fff;
  border-radius: 4px;
  overflow: hidden;
  position: relative;
}

.phone-screen-content {
  padding: 10px;
  height: 100%;
  overflow: auto;
}

.no-preview-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: #909399;
}

.no-preview-content i {
  font-size: 48px;
  margin-bottom: 10px;
}

.no-preview-content p {
  margin: 0;
}

.phone-footer {
  height: 30px;
  display: flex;
  justify-content: center;
  align-items: center;
}

.phone-home-button {
  width: 40px;
  height: 5px;
  background-color: #333;
  border-radius: 3px;
}

.template-details {
  flex: 1;
  min-width: 0;
}

.detail-section {
  background-color: #fff;
  border-radius: 4px;
  padding: 20px;
  margin-bottom: 20px;
  box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.05);
}

.detail-section h3 {
  margin-top: 0;
  padding-bottom: 10px;
  border-bottom: 1px solid #ebeef5;
  margin-bottom: 15px;
  font-size: 16px;
  color: #303133;
}

.info-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 15px;
}

.info-item {
  width: calc(50% - 8px);
  display: flex;
  align-items: flex-start;
}

.info-item.full-width {
  width: 100%;
}

.label {
  font-weight: bold;
  color: #606266;
  min-width: 80px;
  text-align: right;
  margin-right: 10px;
}

.value {
  flex: 1;
  color: #303133;
  word-break: break-all;
}

.sms-example {
  margin-top: 15px;
}

.sms-example :deep(.el-textarea__inner) {
  background-color: #f5f7fa;
  border-color: #e4e7ed;
  color: #606266;
}

.status-ribbon {
  position: absolute;
  top: 0;
  right: 0;
  padding: 4px 8px;
  color: #fff;
  font-size: 12px;
  font-weight: 500;
  z-index: 1;
  border-radius: 0 4px 0 4px;
}

.status-ribbon::before {
  display: none;
}

.status-ribbon-info {
  background-color: rgba(24, 144, 255, 0.8);
}

.status-ribbon-warning {
  background-color: rgba(250, 173, 20, 0.8);
}

.status-ribbon-success {
  background-color: rgba(82, 196, 26, 0.8);
}

.status-ribbon-danger {
  background-color: rgba(255, 77, 79, 0.8);
}

.status-indicator {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: 4px;
  font-size: 13px;
  font-weight: 500;
  background-color: rgba(255, 255, 255, 0.9);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
}

.status-indicator i {
  font-size: 16px;
}

.status-ribbon-info,
.status-indicator.status-ribbon-info i {
  color: #1890ff;
}

.status-ribbon-warning,
.status-indicator.status-ribbon-warning i {
  color: #faad14;
}

.status-ribbon-success,
.status-indicator.status-ribbon-success i {
  color: #52c41a;
}

.status-ribbon-danger,
.status-indicator.status-ribbon-danger i {
  color: #ff4d4f;
}

/* 选中卡片样式 */
.card-selected {
  border-color: #409eff;
  box-shadow: 0 0 5px rgba(64, 158, 255, 0.5);
}

/* 选中标记样式 */
.selection-indicator {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 2;
  color: #409eff;
  font-size: 16px;
}

.template-status-switch {
  position: absolute;
  top: 190px;
  right: 10px;
  z-index: 10;
  display: flex;
  align-items: center;
  background-color: rgba(255, 255, 255, 0.95);
  padding: 6px 10px;
  border-radius: 4px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
  cursor: pointer;
}

.template-status-switch:hover {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.switch-label {
  font-size: 12px;
  font-weight: 500;
  margin-right: 8px;
  color: #606266;
}

.switch-label.enabled {
  color: #13ce66;
}

.switch-label.disabled {
  color: #ff4949;
}

.template-status {
  margin-top: 5px;
  font-size: 12px;
}

.status-enabled {
  color: #13ce66;
  font-weight: 500;
}

.status-disabled {
  color: #ff4949;
  font-weight: 500;
}

.manufacturer-icons {
  display: flex;
  gap: 4px;
  margin-top: 8px;
  align-items: center;
}

.manufacturer-icon {
  width: 20px;
  height: 20px;
  color: #606266;
}

.manufacturer-icon:hover {
  color: #409eff;
}
</style>
